<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns status information on a mailbox</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imap-status" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imap_status</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imap_status</span> &mdash; <span class="dc-title">Returns status information on a mailbox</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imap-status-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imap_status</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$imap_stream</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$mailbox</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>
   ) : <span class="type">object</span></div>

  <p class="para rdfs-comment">
   Gets status information about the given <code class="parameter">mailbox</code>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imap-status-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<code class="parameter">
imap_stream</code></dt>
<dd>
<p class="para">由 <span class="function"><a href="imap_open.html" class="function">imap_open()</a></span> 返回的 IMAP 流。</p></dd>

    
     <dt>
<code class="parameter">mailbox</code></dt>

     <dd>

      <p class="para">
       The mailbox name, see <span class="function"><a href="imap_open.html" class="function">imap_open()</a></span> for more
       information
      </p>
      <div class="warning"><strong class="warning">Warning</strong><p class="simpara">
Passing untrusted data to this parameter is <em class="emphasis">insecure</em>, unless
<a href="imap.configuration.html#ini.imap.enable-insecure-rsh" class="link">imap.enable_insecure_rsh</a> is disabled.
</p></div>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       Valid flags are:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_MESSAGES</code></strong> - set <var class="varname"><var class="varname">$status->messages</var></var> to the
          number of messages in the mailbox
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_RECENT</code></strong> - set <var class="varname"><var class="varname">$status->recent</var></var> to the number
          of recent messages in the mailbox
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_UNSEEN</code></strong> - set <var class="varname"><var class="varname">$status->unseen</var></var> to the number
          of unseen (new) messages in the mailbox
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_UIDNEXT</code></strong> - set <var class="varname"><var class="varname">$status->uidnext</var></var> to the next
          uid to be used in the mailbox
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_UIDVALIDITY</code></strong> - set <var class="varname"><var class="varname">$status->uidvalidity</var></var> to a
          constant that changes when uids for the mailbox may no longer be
          valid
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>SA_ALL</code></strong> - set all of the above
         </span>
        </li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imap-status-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   This function returns an object containing status information.
   The object has the following properties: <em>messages</em>,
   <em>recent</em>, <em>unseen</em>, 
   <em>uidnext</em>, and <em>uidvalidity</em>.  
  </p>
  <p class="para">
   <em>flags</em> is also set, which contains a bitmask which can
   be checked against any of the above constants.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imap-status-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4039">
    <p><strong>Example #1 <span class="function"><strong>imap_status()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$mbox&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_open</span><span style="color: #007700">(</span><span style="color: #DD0000">"{imap.example.com}"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"username"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">OP_HALFOPEN</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"can't&nbsp;connect:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">imap_last_error</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"{imap.example.org}INBOX"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SA_ALL</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$status</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Messages:&nbsp;&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$status</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">messages&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Recent:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$status</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">recent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unseen:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$status</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unseen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"UIDnext:&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$status</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">uidnext&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"UIDvalidity:"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$status</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">uidvalidity&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"imap_status&nbsp;failed:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">imap_last_error</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">imap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$mbox</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>